<template>
    <view>
        <view class="detail_BN" :style="'--color:' + color + ';--rgbcolor:' + rgbcolor + ';'">
            <image mode="widthFix" :src="D.banner"></image>
            <view @tap="my_infoFn" class="photo_s">
                <view class="em">
                    <view class="h4">
                        {{ D.cook_tg_nickname }}
                        <text class="id ico">（ID:{{ D.cook_tg_id }}）</text>
                    </view>
                    <view class="gradeico">
                        当前等级：
                        <image mode="aspectFit" :src="D.cook_tg_grade_ico"></image>
                        <text class="span">{{ D.cook_tg_grade_title }}</text>
                    </view>
                </view>
            </view>
        </view>
        <block v-if="LIST">
            <view :class="'vipli' + (index == 0 ? ' vipli1' : '')" :style="'--color:' + color + ';--rgbcolor:' + rgbcolor + ';'" v-for="(item, index) in LIST" :key="index">
                <view class="title">
                    <image mode="aspectFit" :src="item.grade_ico"></image>
                    <view class="h3">{{ item.grade_title }}</view>
                </view>

                <view class="pricebox">
                    <text class="price" v-if="item.price > 0">
                        现价 ￥
                        <text class="b">{{ item.price }}</text>
                    </text>
                    <text class="price lv" v-else>免费</text>
                    <text class="price2">原价: ￥{{ item.price2 }}</text>
                </view>

                <view class="condition" v-if="item.vip_tj_minUnum > 0">
                    需要推广满
                    <text class="font">{{ item.vip_tj_minUnum }}</text>
                    个用户（单身+合伙人）可升级
                </view>

                <view class="title2">
                    <block v-if="!globalUtils.empty(item.title2)">{{ item.title2 }}</block>
                    <block v-else>升级{{ item.grade_title }}等级，获得更多推广收益。</block>
                </view>

                <button @tap="vipFn" class="btn3" :data-grade="item.grade" type="button">立即升级</button>

                <view class="linebox" style="margin-top: 5px">
                    <view class="line W50"></view>
                    <view class="title BAI" style="color: #999">{{ item.grade_title }}特权/奖励比例</view>
                </view>

                <view class="detaill" :style="vip_height">
                    <view class="dl" v-for="(item2, index1) in item.HELP" :key="index1">
                        <text class="dt">{{ item2.t }}</text>

                        <rich-text class="dd" :nodes="item2.c"></rich-text>
                    </view>
                </view>

                <view @tap="vipmoreFn" class="morebtn">
                    <text class="ico">{{ morebtn_ico }}</text>
                </view>
            </view>
        </block>
        <view class="box" :style="'--color:' + color + ';--rgbcolor:' + rgbcolor + ';'" v-else>
            <view class="nodata">
                <image mode="aspectFit" src="/static/res/img/nodata.png"></image>
                亲，暂时无需升级
            </view>
        </view>
        <view class="blank"></view>
    </view>
</template>
<script>
import globalUtils from "../../res/www.a9a.cn";

var t;
var a = require('../../@babel/runtime/helpers/defineProperty');
var o = require('../../res/www.a9a.cn.js');
var app = getApp();
export default {
  computed: {
    globalUtils() {
      return globalUtils
    }
  },
    data() {
        return {
            vip_height: 'height:10rpx;max-height:10rpx;',
            morebtn_ico: '',
            vip_morebtn_onoff: 'off',
            nTitle: '我的推广中心',
            btm_nav: 'my',
            btmnavbg_color: '#B8BCCC',
            btmnavbg_rgbcolor: o.c16_rgb('#B8BCCC'),
            mask_class: 'alpha0_100',
            color: '',
            rgbcolor: '',
            LIST: '',
            SHARE: '',
            MB: '',

            D: {
                banner: '',
                cook_tg_id: '',
                cook_tg_grade_ico: '',
                cook_tg_grade_title: ''
            },

            div_login: false,
            div_outlist_box_class: ''
        };
    },
    onLoad: function (t) {
        var that = this;
        var i = this;
        app.globalData.get_config('_ZEAI').then(function (t) {
            i.setData({
                color: app.globalData._ZEAI.color,
                rgbcolor: o.c16_rgb(app.globalData._ZEAI.color)
            });
            uni.setNavigationBarColor({
                backgroundColor: '#FF5D48',
                frontColor: '#ffffff'
            });
            uni.setBackgroundColor({
                backgroundColorTop: '#FF5D48'
            });
        });
        app.globalData.get_openid().then(function (t) {
            that.init();
        });
    },
    onPullDownRefresh: function () {
        var that = this;
        uni.vibrateShort({
            type: 'heavy'
        });
        setTimeout(function () {
            uni.stopPullDownRefresh();
            that.init();
        }, 500);
    },
    onShareAppMessage: function (t) {
        return {
            imageUrl: this.SHARE.imgurl,
            title: this.SHARE.title,
            path: '/hnPages/tg/my_vip'
        };
    },
    onShareTimeline: function () {
        return {
            imageUrl: this.SHARE.imgurl,
            title: this.SHARE.title,
            query: '',
            path: '/hnPages/tg/my_vip'
        };
    },
    methods: {
        init: function () {
            var that = this;
            uni.showNavigationBarLoading();
            t = uni.getStorageSync('COOK_U');
            app.globalData.ajax({
                url: 'tg.php',
                data: {
                    submitok: 'MY_VIP',
                    openid: t.openid
                },
                success: function (t) {
                    switch ((uni.hideNavigationBarLoading(), t.flag)) {
                        case '1':
                        case 1:
                            var e = t.D.color;
                            that.setData({
                                LIST: t.LIST,
                                SHARE: t.SHARE,
                                MB: t.MB,
                                nTitle: t.nTitle,
                                D: t.D
                            });
                            uni.setNavigationBarColor({
                                backgroundColor: e,
                                frontColor: '#ffffff'
                            });
                            uni.setNavigationBarTitle({
                                title: t.nTitle
                            });
                            uni.setBackgroundColor({
                                backgroundColorTop: e
                            });
                            break;
                        case 'flag0':
                        case 'flag_1':
                        case 'flag2':
                            uni.reLaunch({
                                url: 'reg?t=' + t.flag
                            });
                            break;
                        default:
                            t.this = that;
                            t.url = 'no';
                            o.sorry(t);
                    }
                }
            });
        },

        vipFn: function (a) {
            var i = a.currentTarget.dataset.grade;
            var that = this;
            o.empty(that.MB) || app.globalData.openSetting(that.MB);
            uni.showNavigationBarLoading();
            t = uni.getStorageSync('COOK_U');
            app.globalData.ajax({
                url: 'tg.php',
                data: {
                    submitok: 'MY_VIP_update',
                    grade: i,
                    openid: t.openid
                },
                success: function (a) {
                    switch ((uni.hideNavigationBarLoading(), a.flag)) {
                        case '1':
                        case 1:
                            uni.showModal({
                                content: a.msg,
                                confirmColor: that.color,
                                confirmText: '朕知道了',
                                showCancel: false,
                                success: function (t) {
                                    uni.redirectTo({
                                        url: '/pages/tg/my'
                                    });
                                }
                            });
                            break;
                        case 'pay':
                            app.globalData.pay({
                                data: {
                                    submitok: 'tg_pay_vip',
                                    grade: i,
                                    openid: t.openid
                                },
                                success: function () {
                                    uni.redirectTo({
                                        url: '/pages/tg/my'
                                    });
                                },
                                fail: function (t) {
                                    t.this = that;
                                    t.url = 'no';
                                    o.sorry(t);
                                }
                            });
                            break;
                        case 'flag0':
                        case 'flag_1':
                        case 'flag2':
                            uni.reLaunch({
                                url: 'reg?t=' + a.flag
                            });
                            break;
                        default:
                            a.this = that;
                            a.url = 'no';
                            o.sorry(a);
                    }
                }
            });
        },

        vipmoreFn: function () {
            if ('off' == this.vip_morebtn_onoff) {
                this.setData({
                    vip_morebtn_onoff: 'on',
                    morebtn_ico: '',
                    vip_height: 'height:auto;max-height:1000rpx;'
                });
            } else {
                this.setData({
                    vip_morebtn_onoff: 'off',
                    morebtn_ico: '',
                    vip_height: 'height:10rpx;max-height:10rpx;'
                });
            }
        },

        back: function () {
            this.setData({
                div_login: false
            });
        },

        mask_closeFn: function (t) {
            var that = this;
            var e = t.currentTarget.dataset.maskid;
            this.setData({
                mask_class: 'alpha100_0',
                div_outlist_box_class: 'div_upAnm2'
            });
            setTimeout(function () {
                var t;
                that.setData((a((t = {}), e, false), a(t, 'mask_class', 'alpha0_100'), a(t, 'div_outlist_box_class', 'div_upAnm1'), t));
            }, 500);
        },

        emptyFn: function () {},

        my_infoFn() {
            console.log('占位：函数 my_infoFn 未声明');
        }
    }
};
</script>
<style>
@import 'my_vip.css';
</style>
